#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main()
{
	int a = 0;
	int b = 0;
	scanf("%d %d", &a, &b);
	
	int c = 1;
	int d = 1;
	do
	{
		if (a >= b)
		{
			d = c;
			c = a % b;
			a = c;
		}
		else if (a < b)
		{
			d = c;
			c = b % a;
			b = c;
		};

	} while (c != 0);
	printf("%d", d);
	return 0;
}